-- set_owner_data
--
local import = import
---@type behavior_ret
local bret = import('bt/bt_plugin/behavior3/behavior_ret')
---@type OWNER_VALUE_TYPE
local OWNER_VALUE_TYPE = import('bt/custom_node/enum_type_cfg/OWNER_VALUE_TYPE')
local M = {
    name = "set_owner_data",
    type = "Action",
    desc = "设置owner数据",
    args = {
        {
            name = 'name',
            type = 'enum',
            desc = '变量类型',
            options = OWNER_VALUE_TYPE
        },
        { "numI", "int?", "整形" },
        { "numF", "float?", "浮点数" },
        { "str", "string?", "字符串" },
    },
    input = { "数据?" },
    output = { "数据?" },
}

function M.run(node, env, value)
    local owner = env.owner
    local name = node.args.name
    local numI = node.args.numI
    local numF = node.args.numF
    local str = node.args.str
    local setValue = nil
    if numI then
        setValue = numI
    end
    if numF then
        setValue = numF
    end
    if str then
        setValue = str
    end
    if value then
        setValue = value
    end
    owner[name] = setValue
    return bret.SUCCESS, setValue
end

return M
